/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package SessionBeans;

import Classes.Bug;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Tomas
 */
@Stateless
public class BugFacade implements BugFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Bug bug) {
        em.persist(bug);
    }

    public void edit(Bug bug) {
        em.merge(bug);
    }

    public void remove(Bug bug) {
        em.remove(em.merge(bug));
    }

    public Bug find(Object id) {
        return em.find(Classes.Bug.class, id);
    }

    public List<Bug> findAll() {
        return em.createQuery("select object(o) from Bug as o").getResultList();
    }

}
